<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>CRM</title>
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<link rel="stylesheet" href="css/bootstrap-responsive.min.css" />
	<link rel="stylesheet" href="css/jquery.validity.css"/>
</head>
<body>
	<%@ include file="include/loginhead.jsp" %>
	
	<div class="container" style="margin-top:60px">
		<div class="page-header">
			<h4>请登录</h4>
		</div>
		
<div class="row">
	<div class="span8">
	<div class="alert alert-alert" style="display:none;">
      <h4 class="alert-heading"></h4>
    </div>
	<form novalidate="novalidate" method="post" action="javascript:;" id="user-form" class="simple_form well" accept-charset="UTF-8">
		<div class="control-group email required">
		<div class="controls">
		<input type="text" title="Email" size="50" placeholder="Email" name="user.email" id="user_email" class="string email required span3"/>
		</div>
		</div>
	  
		<div class="control-group password required">
		<div class="controls">
		<input type="password" title="密码" size="50" placeholder="密码" name="user.password" id="user_password" class="password required span3"/>
		</div>
		</div>
		<div class="control-group optional">
	 	</div>
		
	  	<button type="button" id="commit" class="btn btn btn-primary">登 录</button>
		<a href="/crm/findpwd.jspx">忘了密码?</a>
	</form>
	</div>
	<div class="span4">
		<div class="well">
		<div>
		  	<a href="/crm/gosign.jspx">创建帐号</a><br/>
		  	<a href="/crm/findpwd.jspx">忘记了密码?</a><br/>
		 	<a href="/crm/newConfirmation.jspx">没有收到确认邮件?</a><br/>
		</div>
		</div>
	</div>
	</div>
	</div>
	
	<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
	<script type="text/javascript" src="js/jquery.validity.js"></script>
	<script type="text/javascript" charset="UTF-8" src="js/jquery.validity.lang.zh.js"></script>
	<script type="text/javascript">
	$(function() {
		var result;
		$("#commit").click(function() {
			$(this).text("处理中...");
			$("#user-form").submit();
			if(result) {
				$.post("login.jspx",{"user.email" : $("#user_email").val().trim(), "user.password" : $("#user_password").val().trim()}, function(msg) {
					if(msg == 1) {
						window.location = "getproduct.jspx";
					} else if(msg == 2) {
						$(".alert-heading").text("账户未激活，请查收确认信息邮件，或者<a href=\"/crm/newConfirmation.jspx>\"重新发送确认邮件</a>。");
						$(".alert").show();
						$("#commit").text("登 录");
					} else {
						$(".alert-heading").text("Email或密码错误！");
						$(".alert").show();
						$("#commit").text("登 录");
					}
				});
			} else {
				$("#commit").text("登 录");
			}
		});
			
			$("#user-form").validity(function() {
				$("#user_email").require().match("email");
				$("#user_password").require().minLength(6).maxLength(20);
				result = $.validity.end().valid;
			});
		});
	</script>
	
</body>
</html>